{template "header.html"}

<div class="note note-danger">
    <p>{dr_lang('如果你的数据库账号没有高级操作权限，将无法获取数据表信息')}</p>
</div>


<div class="right-card-box">
<form class="form-horizontal" role="form" id="myform">
    {dr_form_hidden()}
    <div class="table-scrollable">
        <table class="table table-striped table-bordered table-hover table-checkable dataTable">
            <thead>
            <tr class="heading">
                {if $ci->_is_admin_auth('del')}
                <th class="myselect">
                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                        <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                        <span></span>
                    </label>
                </th>
                {/if}
                <th width="250">{dr_lang('表名')}</th>
                <th width="150">{dr_lang('描述')}</th>
                <th width="100">{dr_lang('记录')}</th>
                <th width="100">{dr_lang('容量')}</th>
                <th width="100">{dr_lang('引擎')}</th>
                <th width="160">{dr_lang('最近更新')}</th>
                <th><a href="javascript:;" style="color:red" onclick="dr_check_table()">{dr_lang('检查表异常')}</a></th>
            </tr>
            </thead>
            <tbody>
            {loop $list $t}
            <tr class="odd gradeX">
                {if $ci->_is_admin_auth('del')}
                <td class="myselect">
                    <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                        <input type="checkbox" class="checkboxes" name="ids[]" value="{$t.Name}" />
                        <span></span>
                    </label>
                </td>
                {/if}
                <td><a href="javascript:dr_iframe_show('{dr_lang('表结构')}', '{dr_url($uriprefix.'/show_index', ['id'=>$t.Name])}');">{$t.Name}</a></td>
                <td><a href="javascript:dr_iframe_show('{dr_lang('表结构')}', '{dr_url($uriprefix.'/show_index', ['id'=>$t.Name])}');">{$t.Comment}</a></td>
                <td>{$t.Rows}</td>
                <td>{dr_format_file_size($t.Data_length)}</td>
                <td>{$t.Engine}</td>
                <td>{$t.Update_time}</td>
                <td class="dr_check_table" id="dr_row_{$t.Name}"></td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>

     <div class="row fc-list-footer table-checkable ">
         <div class="col-md-5 fc-list-select">
            <label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
                <input type="checkbox" class="group-checkable" data-set=".checkboxes" />
                <span></span>
            </label>
            <button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/all', ['at'=>'y'])}', '{dr_lang('你确定要这样操作吗？')}', 1)" class="btn green btn-sm"> <i class="fa fa-refresh"></i> {dr_lang('优化表')}</button>
            <button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/all', ['at'=>'x'])}', '{dr_lang('你确定要这样操作吗？')}', 1)" class="btn blue btn-sm"> <i class="fa fa-wrench"></i> {dr_lang('修复表')}</button>
            <button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/all', ['at'=>'s'])}', '{dr_lang('你确定要这样操作吗？')}', 1)" class="btn red btn-sm"> <i class="fa fa-retweet"></i> {dr_lang('刷新表')}</button>
        </div>
        <div class="myright">

        </div>
    </div>
</form></div>

<script type="text/javascript">
    function dr_check_table() {
        $(".dr_check_table").html("<img style='height:17px' src='{THEME_PATH}assets/images/loading-0.gif'>");
        {loop $list $t}
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{dr_url($uriprefix.'/check_index', ['id'=>$t.Name])}",
            success: function(json) {
                $("#dr_row_{$t.Name}").html(json.msg);
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                $("#dr_row_{$t.Name}").html("error");
            }
        });
        {/loop}
    }
</script>

{template "footer.html"}